//
//  EFengMemberSelectionCell.m
//  WZEfengAndEtong
//
//  Created by wanzhao on 16/1/21.
//  Copyright © 2016年 wanzhao. All rights reserved.
//

#import "EFengMemberSelectionCell.h"

@implementation EFengMemberSelectionCell
+ (instancetype)eFengMemberSelectionCellWithTableView:(UITableView *)tableView
{
    static NSString *EFengMemberSelectionCellId = @"EFengMemberSelectionCellId";
    EFengMemberSelectionCell *cell = [tableView dequeueReusableCellWithIdentifier:EFengMemberSelectionCellId];
    if (cell == nil) {
        cell = [[EFengMemberSelectionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:EFengMemberSelectionCellId];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupMemSub];
    }
    return self;
}


- (void)setupMemSub
{
    //    WeakProperty UIView *seperatorLine;
    //    WeakProperty UILabel *departNameLabel;
    //    WeakProperty UIImageView *rightArrow;
    //    WeakProperty UILabel *departCountLabel;
    //    WeakProperty UIButton *departIcon;
    //    WeakProperty UIButton *selectIcon;
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@"ico-circleDefault"] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:@"ico-circleClick"] forState:UIControlStateSelected];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:btn];
    self.selectIcon = btn;
    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn1 setImage:[UIImage imageNamed:@"icon-man"] forState:UIControlStateNormal];
    btn1.userInteractionEnabled = NO;
    [self.contentView addSubview:btn1];
    self.sexIcon = btn1;
    
    
    UIView *sepratiorline = [[UIView alloc] init];
    sepratiorline.backgroundColor = RGBCOLOR(212, 212, 212);
    [self.contentView addSubview:sepratiorline];
    self.seperatorLine = sepratiorline;
    
    
    UIView *shortline = [[UIView alloc] init];
    shortline.backgroundColor = RGBCOLOR(212, 212, 212);
    [self.contentView addSubview:shortline];
    self.shortLine = shortline;

    
    UILabel *label1 = [[UILabel alloc] init];
    label1.textAlignment = UITextAlignmentLeft;
    label1.textColor = BlackColor;
    [self.contentView addSubview:label1];
    self.userNameLabel = label1;
    
    UILabel *label2 = [[UILabel alloc] init];
    label2.textAlignment = UITextAlignmentRight;
    label2.textColor = BlackColor;
    [self.contentView addSubview:label2];
    self.positionLabel = label2;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    self.selectIcon.frame = CGRectMake(0.0f, 0, self.selectIcon.currentImage.size.width + 30.0f, self.height);
    self.sexIcon.frame = CGRectMake(CGRectGetMaxX(self.selectIcon.frame), 0, self.sexIcon.currentImage.size.width, self.height);
    
    self.positionLabel.frame = CGRectMake(self.width - 100.0f - 10.0f, 0, 100.0f, self.height);
    self.userNameLabel.frame = CGRectMake(CGRectGetMaxX(self.sexIcon.frame) + 5.0f, 0, self.positionLabel.x - CGRectGetMaxX(self.sexIcon.frame) - 5.0f, self.height);
    self.seperatorLine.frame = CGRectMake(0, self.height - 0.5f, self.width, 0.5f);
    self.shortLine.frame = CGRectMake(10.0f, self.height - 0.5f, self.width - 10.0f, 0.5f);
}
- (void)btnClick
{
    if ([self.eFengMemberSelectionCellDelegate respondsToSelector:@selector(eFengMemberSelectionCellDidSelecWithIndexPath:tableView:)]) {
        [self.eFengMemberSelectionCellDelegate eFengMemberSelectionCellDidSelecWithIndexPath:self.cellIndexPath tableView:self.tableView];
    }
}

@end
